package com.zmn.plat.services.impl.orderconfig.serviceaudit;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zmn.common.dto.StatusDTO;
import com.zmn.plat.model.entity.orderconfig.serviceaudit.OrderServiceAuditReason;
import com.zmn.plat.model.entity.orderconfig.serviceaudit.OrderServiceAuditReasonQuery;
import com.zmn.plat.persistence.interfaces.orderconfig.serviceaudit.OrderServiceAuditReasonDao;
import com.zmn.plat.services.interfaces.orderconfig.serviceaudit.OrderServiceAuditReasonService;

/**
 * @author tanbiao
 * @description
 * @since 2020/09/16 18:17
 * @modifier
 **/
@Service
public class OrderServiceAuditReasonServiceImpl implements OrderServiceAuditReasonService {
    @Autowired
    private OrderServiceAuditReasonDao orderServiceAuditReasonDao;

    @Override
    public OrderServiceAuditReason findByKey(int id) {
        return orderServiceAuditReasonDao.findByKey(id);
    }

    @Override
    public List<OrderServiceAuditReason> findByKeys(List<Integer> ids) {
        return orderServiceAuditReasonDao.findByKeys(ids);
    }

    @Override
    public Integer findMaxSort() {
        return orderServiceAuditReasonDao.findMaxSort();
    }

    @Override
    public List<OrderServiceAuditReason> listByQuery(OrderServiceAuditReasonQuery query) {
        return orderServiceAuditReasonDao.listByQuery(query);
    }

    @Override
    public List<OrderServiceAuditReason> listPageByQuery(OrderServiceAuditReasonQuery query) {
        return orderServiceAuditReasonDao.listPageByQuery(query);
    }

    @Override
    public Integer countByQuery(OrderServiceAuditReasonQuery query) {
        return orderServiceAuditReasonDao.countByQuery(query);
    }

    @Override
    public Integer updateByKey(OrderServiceAuditReason reason) {
        return orderServiceAuditReasonDao.updateByKey(reason);
    }

    @Override
    public Integer updateSortKey(Integer id, Integer sort, String staffName) {
        OrderServiceAuditReason reason = new OrderServiceAuditReason();
        reason.setId(id);
        reason.setSort(sort);
        reason.setUpdateTime(new Date());
        reason.setUpdater(staffName);
        return orderServiceAuditReasonDao.updateSortKey(reason);
    }

    @Override
    public Integer updateFirstLetterByKey(Integer id, String firstLetter, String staffName) {
        OrderServiceAuditReason reason = new OrderServiceAuditReason();
        reason.setId(id);
        reason.setFirstLetter(firstLetter);
        reason.setUpdateTime(new Date());
        reason.setUpdater(staffName);
        return orderServiceAuditReasonDao.updateFirstLetterByKey(reason);
    }

    @Override
    public int updateStatusBatch(List<Integer> ids, Integer status, String staffName) {
        StatusDTO dto = new StatusDTO();
        dto.setIds(ids);
        dto.setStatus(status);
        dto.setUpdater(staffName);
        dto.setUpdateTime(new Date());
        return orderServiceAuditReasonDao.updateStatusBatch(dto);
    }

    @Override
    public Integer insert(OrderServiceAuditReason reason) {
        return orderServiceAuditReasonDao.insert(reason);
    }

    @Override
    public Integer deleteByKey(Integer id) {
        return orderServiceAuditReasonDao.deleteByKey(id);
    }
}
